package com.atguigu.yygh.task.schedule;

import com.atguigu.yygh.rabbit.RabbitService;
import com.atguigu.yygh.rabbit.constant.MqConst;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling//开启定时任务
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    /**
     * 每天8点执行 提醒就诊
     */
    //@Scheduled(cron = "0 0 20 * * ?")
    @Scheduled(cron = "0/5 * * * * ?")//TODO 测试
    public void task1 (){
        //查询日期 第二天日期
        DateTime dateTime = new DateTime().plusDays(1);
        //转换成字符串
        String dateString = dateTime.toString("yyyy-MM-dd");
        System.out.println(dateString);

        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,
                MqConst.ROUTING_TASK_8, dateString);

    }
}
